package com.naizhuai.Model.db.managenote;

import com.naizhuai.Model.db.eneity.ManageNoteBean;
import com.naizhuai.Model.db.search.SearchHistoryBean;

import java.util.List;

/**
 * @author：lichenxi
 * @date 2018/2/27 19
 * email：525603977@qq.com
 * Fighting
 */
public class ManageNoteRepository implements ManageNoteSourse {
    private static ManageNoteRepository INSTANCE = null;

    private ManageNoteSourse localManageNoteData;
    private ManageNoteSourse remoteManageNoteData;

    public ManageNoteRepository(ManageNoteSourse localManageNoteData, ManageNoteSourse remoteManageNoteData) {
        this.localManageNoteData = localManageNoteData;
        this.remoteManageNoteData = remoteManageNoteData;
    }

    public  static ManageNoteRepository getInstance(ManageNoteSourse localManageNoteData, ManageNoteSourse remoteManageNoteData ){
        if (INSTANCE==null){
            INSTANCE=new ManageNoteRepository(localManageNoteData,remoteManageNoteData);
        }
        return INSTANCE;
    }


    @Override
    public void getNoteDataAsyn(int status, GetManageNoteCallback callback) {
        localManageNoteData.getNoteDataAsyn(status, new GetManageNoteCallback() {
            @Override
            public void onGetStateData(List<ManageNoteBean> search) {
                callback.onGetStateData(search);
            }

            @Override
            public void onDataNotAvailable() {
                callback.onDataNotAvailable();
            }
        });
    }

    @Override
    public void saveNoteData(List<ManageNoteBean> search) {
        localManageNoteData.saveNoteData(search);
    }

    @Override
    public void saveManageNoteSingleData(ManageNoteBean search) {
        localManageNoteData.saveManageNoteSingleData(search);
    }

    @Override
    public void deleteManageNoteData(ManageNoteBean bean) {
        localManageNoteData.deleteManageNoteData(bean);
    }
}
